package com.xbongbong.test;

import com.xbongbong.paas.enums.BiRelTableEnum;
import com.xbongbong.paas.pojo.CustomCardPoJo;
import com.xbongbong.pro.activity.pojo.dto.ActivityGetDTO;
import com.xbongbong.pro.constant.I18nStringConstant;
import com.xbongbong.pro.enums.ErrorCodeEnum;
import com.xbongbong.pro.message.enums.PushTypeEnum;
import com.xbongbong.pro.statistic.enums.IndicatorRuleEnum;
import org.junit.Test;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Map;
import java.util.Objects;

/**
 * @author ly1666
 * @date 2020/3/7 10:29 AM
 */
public class EnumI18nMsgPropertiesGenerator {

    private static String ERROR_CODE_ENUM_PROPERTIES_PREFIX =  "enum.errorCode.msg.";

    private static String DTO_MSG = "dto.msg.";

    private static String POJO_MSG = "pojo.msg.";

    private static String JAVAX_VALIDATION_CONSTRAINTS_NOTNULL = "javax.validation.constraints.NotNull";

    private static String JAVAX_VALIDATION_CONSTRAINTS_NOTBLANK = "javax.validation.constraints.NotBlank";

    private static String ORG_HIBERNATE_VALIDATOR_CONSTRAINTS_LENGTH = "org.hibernate.validator.constraints.Length";

    private static String JAVAX_VALIDATION_VALID = "javax.validation.Valid";

    private static String JAVAX_VALIDATION_CONSTRAINTS_MIN = "javax.validation.constraints.Min";

    private static String JAVAX_VALIDATION_CONSTRAINTS_MAX = "javax.validation.constraints.Max";

    private static String JAVAX_VALIDATION_CONSTRAINTS_NOTEMPTY = "javax.validation.constraints.NotEmpty";

    private static String JAVAX_VALIDATION_CONSTRAINTS_SIZE = "javax.validation.constraints.Size";

    private static String ORG_HIBERNATE_VALIDATOR_CONSTRAINTS_RANGE = "org.hibernate.validator.constraints.Range";

    private static String JAVAX_VALIDATION_CONSTRAINTS_DECIMALMIN = "javax.validation.constraints.DecimalMin";

    private static String JAVAX_VALIDATION_CONSTRAINTS_DECIMALMAX = "javax.validation.constraints.DecimalMax";

    private static String JAVAX_VALIDATION_CONSTRAINTS_SIZE$LIST = "javax.validation.constraints.Size$List";

    private static String CODE_ENUM_PROPERTIES_PREFIX =  "enum.";

    private static String CONSTANT_NAME = "constant.";

    private static String MSG = ".msg.";

    public static void main(String[] args) {
        // errorCode 枚举
        for (ErrorCodeEnum errorCodeEnum : ErrorCodeEnum.values()) {
            StringBuilder propertiesSb = new StringBuilder();
            propertiesSb.append(ERROR_CODE_ENUM_PROPERTIES_PREFIX)
                    .append(errorCodeEnum.name().toLowerCase())
                    .append("=")
                    .append(errorCodeEnum.getMsg());
            System.out.println(propertiesSb.toString());
        }

        // errorCode 枚举替换
//        for (ErrorCodeEnum errorCodeEnum : ErrorCodeEnum.values()) {
//            StringBuilder propertiesSb = new StringBuilder();
//            propertiesSb.append("\t")
//                    .append(errorCodeEnum.name())
//                    .append("(")
//                    .append(errorCodeEnum.getCode())
//                    .append(", ")
//                    .append("\"")
//                    .append(ERROR_CODE_ENUM_PROPERTIES_PREFIX)
//                    .append(errorCodeEnum.name().toLowerCase())
//                    .append("\", \"\"),");
//            System.out.println(propertiesSb.toString());
//        }
    }

    @Test
    public void changeDTO() throws NoSuchMethodException,
            IllegalAccessException, IllegalArgumentException,
            InvocationTargetException {
        ActivityGetDTO raidersScoreDTO = new ActivityGetDTO();
        String classname = raidersScoreDTO.getClass().getSimpleName();
        classname = classname.substring(0,1).toLowerCase().concat(classname.substring(1));
        classname = classname.substring(0,classname.length()-3);
        java.lang.reflect.Field[] field = raidersScoreDTO.getClass().getDeclaredFields();
        StringBuilder stringBuilder = new StringBuilder();
        for (int j = 0; j < field.length; j++) {
            // 获取属性的名字
            String name = field[j].getName();
            // 将属性的首字符大写，方便构造get，set方法
            name = name.substring(0, 1).toUpperCase() + name.substring(1);
            // 获取属性的类型
            String type = field[j].getGenericType().toString();
            String memberName = "";
            String sizeValue = "";
            // 如果type是类类型，则前面包含"class "，后面跟类名
            //System.out.println("属性为：" + name);
            // 方法1
            Annotation[] annotations = field[j].getDeclaredAnnotations();
            //Object fieldValue = runGetter(field[j], this);
            for (Annotation annotation : annotations) {
                if (Objects.equals(JAVAX_VALIDATION_CONSTRAINTS_NOTNULL, annotation.annotationType().getName())) {
                    InvocationHandler invocationHandler = Proxy.getInvocationHandler(annotation);
                    try {
                        Field declaredField = invocationHandler.getClass().getDeclaredField("memberValues");
                        declaredField.setAccessible(true);
                        Map memberValues = (Map) declaredField.get(invocationHandler);
                        memberName = memberValues.get("message").toString();
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    }
                    stringBuilder.append(DTO_MSG).append(classname).append(".").append(field[j].getName()).append(".").append("NotNull").append("=").append(memberName);
                    System.out.println(stringBuilder.toString());
                    stringBuilder.delete(0, stringBuilder.length());
                } else if (Objects.equals(JAVAX_VALIDATION_CONSTRAINTS_NOTBLANK, annotation.annotationType().getName())) {
                    InvocationHandler invocationHandler = Proxy.getInvocationHandler(annotation);
                    try {
                        Field declaredField = invocationHandler.getClass().getDeclaredField("memberValues");
                        declaredField.setAccessible(true);
                        Map memberValues = (Map) declaredField.get(invocationHandler);
                        memberName = memberValues.get("message").toString();
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    }
                    stringBuilder.append(DTO_MSG).append(classname).append(".").append(field[j].getName()).append(".").append("NotBlank").append("=").append(memberName);
                    System.out.println(stringBuilder.toString());
                    stringBuilder.delete(0, stringBuilder.length());
                } else if (Objects.equals(ORG_HIBERNATE_VALIDATOR_CONSTRAINTS_LENGTH, annotation.annotationType().getName())) {
                    InvocationHandler invocationHandler = Proxy.getInvocationHandler(annotation);
                    try {
                        Field declaredField = invocationHandler.getClass().getDeclaredField("memberValues");
                        declaredField.setAccessible(true);
                        Map memberValues = (Map) declaredField.get(invocationHandler);
                        memberName = memberValues.get("message").toString();
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    }
                    stringBuilder.append(DTO_MSG).append(classname).append(".").append(field[j].getName()).append(".").append("Length").append("=").append(memberName);
                    System.out.println(stringBuilder.toString());
                    stringBuilder.delete(0, stringBuilder.length());
                } else if (Objects.equals(JAVAX_VALIDATION_CONSTRAINTS_MIN, annotation.annotationType().getName())) {
                    InvocationHandler invocationHandler = Proxy.getInvocationHandler(annotation);
                    try {
                        Field declaredField = invocationHandler.getClass().getDeclaredField("memberValues");
                        declaredField.setAccessible(true);
                        Map memberValues = (Map) declaredField.get(invocationHandler);
                        memberName = memberValues.get("message").toString();
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    }
                    stringBuilder.append(DTO_MSG).append(classname).append(".").append(field[j].getName()).append(".").append("Min").append("=").append(memberName);
                    System.out.println(stringBuilder.toString());
                    stringBuilder.delete(0, stringBuilder.length());
                } else if (Objects.equals(JAVAX_VALIDATION_CONSTRAINTS_MAX, annotation.annotationType().getName())) {
                    InvocationHandler invocationHandler = Proxy.getInvocationHandler(annotation);
                    try {
                        Field declaredField = invocationHandler.getClass().getDeclaredField("memberValues");
                        declaredField.setAccessible(true);
                        Map memberValues = (Map) declaredField.get(invocationHandler);
                        memberName = memberValues.get("message").toString();
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    }
                    stringBuilder.append(DTO_MSG).append(classname).append(".").append(field[j].getName()).append(".").append("Max").append("=").append(memberName);
                    System.out.println(stringBuilder.toString());
                    stringBuilder.delete(0, stringBuilder.length());
                } else if (Objects.equals(JAVAX_VALIDATION_CONSTRAINTS_NOTEMPTY, annotation.annotationType().getName())) {
                    InvocationHandler invocationHandler = Proxy.getInvocationHandler(annotation);
                    try {
                        Field declaredField = invocationHandler.getClass().getDeclaredField("memberValues");
                        declaredField.setAccessible(true);
                        Map memberValues = (Map) declaredField.get(invocationHandler);
                        memberName = memberValues.get("message").toString();
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    }
                    stringBuilder.append(DTO_MSG).append(classname).append(".").append(field[j].getName()).append(".").append("NotEmpty").append("=").append(memberName);
                    System.out.println(stringBuilder.toString());
                    stringBuilder.delete(0, stringBuilder.length());
                } else if (Objects.equals(JAVAX_VALIDATION_CONSTRAINTS_SIZE, annotation.annotationType().getName())) {
                    InvocationHandler invocationHandler = Proxy.getInvocationHandler(annotation);
                    try {
                        Field declaredField = invocationHandler.getClass().getDeclaredField("memberValues");
                        declaredField.setAccessible(true);
                        Map memberValues = (Map) declaredField.get(invocationHandler);
                        memberName = memberValues.get("message").toString();
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    }
                    stringBuilder.append(DTO_MSG).append(classname).append(".").append(field[j].getName()).append(".").append("Size").append("=").append(memberName);
                    System.out.println(stringBuilder.toString());
                    stringBuilder.delete(0, stringBuilder.length());
                } else if (Objects.equals(ORG_HIBERNATE_VALIDATOR_CONSTRAINTS_RANGE, annotation.annotationType().getName())) {
                    InvocationHandler invocationHandler = Proxy.getInvocationHandler(annotation);
                    try {
                        Field declaredField = invocationHandler.getClass().getDeclaredField("memberValues");
                        declaredField.setAccessible(true);
                        Map memberValues = (Map) declaredField.get(invocationHandler);
                        memberName = memberValues.get("message").toString();
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    }
                    stringBuilder.append(DTO_MSG).append(classname).append(".").append(field[j].getName()).append(".").append("Range").append("=").append(memberName);
                    System.out.println(stringBuilder.toString());
                    stringBuilder.delete(0, stringBuilder.length());
                } else if (Objects.equals(JAVAX_VALIDATION_CONSTRAINTS_DECIMALMIN, annotation.annotationType().getName())) {
                    InvocationHandler invocationHandler = Proxy.getInvocationHandler(annotation);
                    try {
                        Field declaredField = invocationHandler.getClass().getDeclaredField("memberValues");
                        declaredField.setAccessible(true);
                        Map memberValues = (Map) declaredField.get(invocationHandler);
                        memberName = memberValues.get("message").toString();
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    }
                    stringBuilder.append(DTO_MSG).append(classname).append(".").append(field[j].getName()).append(".").append("DecimalMin").append("=").append(memberName);
                    System.out.println(stringBuilder.toString());
                    stringBuilder.delete(0, stringBuilder.length());
                } else if (Objects.equals(JAVAX_VALIDATION_CONSTRAINTS_DECIMALMAX, annotation.annotationType().getName())) {
                    InvocationHandler invocationHandler = Proxy.getInvocationHandler(annotation);
                    try {
                        Field declaredField = invocationHandler.getClass().getDeclaredField("memberValues");
                        declaredField.setAccessible(true);
                        Map memberValues = (Map) declaredField.get(invocationHandler);
                        memberName = memberValues.get("message").toString();
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    }
                    stringBuilder.append(DTO_MSG).append(classname).append(".").append(field[j].getName()).append(".").append("DecimalMax").append("=").append(memberName);
                    System.out.println(stringBuilder.toString());
                    stringBuilder.delete(0, stringBuilder.length());
                }
            }
        }
    }
    // 由于所有子类的属性都是private的，所以必须要找到属性的getter方法
    //  以下代码借鉴[stackoverflow的文章](https://stackoverflow.com/questions/13400075/reflection-generic-get-field-value)
    public Object runGetter(Field field, Object instance) {
        // MZ: Find the correct method
        for (Method method : instance.getClass().getDeclaredMethods()) {
            if ((method.getName().startsWith("get")) && (method.getName().length() == (field.getName().length() + 3))) {
                if (method.getName().toLowerCase().endsWith(field.getName().toLowerCase())) {
                    // MZ: Method found, run it
                    try {
                        return method.invoke(instance);
                    } catch (IllegalAccessException | InvocationTargetException e) {
                        System.out.println("Could not determine method: " + method.getName());
                    }
                }
            }
        }
        return null;
    }

    /*@Test
    public void changeEnum() {

        for (TransferStatusEnum errorCodeEnum : TransferStatusEnum.values()) {
            StringBuilder propertiesSb = new StringBuilder();
            propertiesSb.append("\t")
                    .append(errorCodeEnum.name())
                    .append("(")
                    //.append("\"")
                    .append(errorCodeEnum.getCode())
                    //.append("\"")
                    .append(", ")
                    .append("\"")
                    .append(CODE_ENUM_PROPERTIES_PREFIX)
                    .append(getName(errorCodeEnum))
                    .append(MSG)
                    .append(errorCodeEnum.name().toLowerCase())
                    .append("\"")
                    .append(", ")
                    .append("\"")
                    .append(errorCodeEnum.getAttr())
                    .append("\"")
                    .append("),");
                    //.append("\"),");
                    //.append("\", \"\"),");
            System.out.println(propertiesSb.toString());
            System.out.println("\n");
        }
    }*/

    @Test
    public void changeOtherEnum() {

        for (IndicatorRuleEnum errorCodeEnum : IndicatorRuleEnum.values()) {
            StringBuilder propertiesSb = new StringBuilder();
            propertiesSb.append("\t")
                    .append(errorCodeEnum.name())
                    .append("(")
                    .append(errorCodeEnum.getCode())
                    .append(",")
                    //.append(errorCodeEnum.getType())
                    .append("\"")
                    .append(CODE_ENUM_PROPERTIES_PREFIX)
                    //.append(getName(errorCodeEnum))
                    .append(MSG)
                    .append(errorCodeEnum.name().toLowerCase())
                    .append("\"")
                    //.append(errorCodeEnum.getLevel())
                    .append("),");
            //.append("\"),");
            //.append("\", \"\"),");
            System.out.println(propertiesSb.toString());
            System.out.println("\n");
        }
    }

    public String getName(PushTypeEnum errorCodeEnum) {
        String classname = errorCodeEnum.getClass().getSimpleName();
        classname = classname.substring(0,1).toLowerCase().concat(classname.substring(1));
        classname = classname.substring(0,classname.length()-4);
        return classname;
    }

    @Test
    public void propertiesEnum() {
        for (PushTypeEnum errorCodeEnum : PushTypeEnum.values()) {
            StringBuilder propertiesSb = new StringBuilder();
            propertiesSb.append(CODE_ENUM_PROPERTIES_PREFIX)
                    .append(getName(errorCodeEnum))
                    .append(".name.")
                    .append(errorCodeEnum.name().toLowerCase())
                    .append("=")
                    //.append(errorCodeEnum.getUnit());
                    //.append(errorCodeEnum.getTitle());
                    //.append(errorCodeEnum.getLabel());
                    //.append(errorCodeEnum.getValue());
                    .append(errorCodeEnum.getName());
                    //.append(errorCodeEnum.getDescript());
                    //.append(errorCodeEnum.getAttr());
                    //.append(errorCodeEnum.getTitleName());
                    //.append(errorCodeEnum.getSpecialMemo());
                    //.append(errorCodeEnum.getOldName());
                    //.append(errorCodeEnum.getMsg());
                    //.append(errorCodeEnum.getDescribe());
                    //.append(errorCodeEnum.getDescription());
                    //.append(errorCodeEnum.getDesc());
                    //.append(errorCodeEnum.getAlias());
                    //.append(errorCodeEnum.getAttrName());
                    //.append(errorCodeEnum.getMemo());
                    //.append(errorCodeEnum.getText());
            System.out.println(propertiesSb.toString());
        }
    }

    /*@Test
    public void propertiesotherEnum() {
        for (TagEnum errorCodeEnum : TagEnum.values()) {
            StringBuilder propertiesSb = new StringBuilder();
            propertiesSb.append(CODE_ENUM_PROPERTIES_PREFIX)
                    .append(getName(errorCodeEnum))
                    .append(MSG)
                    .append(errorCodeEnum.name().toLowerCase())
                    .append(".")
                    .append("memo")
                    .append("=")
                    //.append(errorCodeEnum.getDescription());
                    //.append(errorCodeEnum.getMsg());
            //.append(errorCodeEnum.getAlias());
            //.append(errorCodeEnum.getName());
                    //.append(errorCodeEnum.getStatus());
                    //.append(errorCodeEnum.getTypeName());
                     .append(errorCodeEnum.getMemo());
            System.out.println(propertiesSb.toString());
        }
    }*/
    @Test
    public void propertiesConstant() {
        I18nStringConstant constant = new I18nStringConstant();
        String classname = constant.getClass().getSimpleName();
        classname = classname.substring(0,1).toLowerCase().concat(classname.substring(1));
        classname = classname.substring(0,classname.length()-8);
        java.lang.reflect.Field[] field = constant.getClass().getDeclaredFields();
        for (int i = 0; i < field.length; i++) {
            // 获取属性的名字
            String name = field[i].getName().toLowerCase();
            try {
                // 获取原来的访问控制权限
                boolean accessFlag = field[i].isAccessible();
                // 修改访问控制权限
                field[i].setAccessible(true);
                // 获取在对象f中属性fields[i]对应的对象中的变量
                Object o;
                try {
                    o = field[i].get(constant);
                    //System.out.println(CONSTANT_NAME + classname + "." + name + " = " + o);
                    System.out.println("\t" + "public static final String " + field[i].getName() + " = \"" + CONSTANT_NAME + classname + "." + name + "\";\n");
                } catch (IllegalAccessException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                // 恢复访问控制权限
                field[i].setAccessible(accessFlag);
            } catch (IllegalArgumentException ex) {
                ex.printStackTrace();
            }
        }
    }

    public String getIndex(BiRelTableEnum errorCodeEnum) {
        StringBuilder stringBuilder = new StringBuilder();
        if (Objects.equals(errorCodeEnum.getIndex(), null)) {
            return null;
        } else {
            stringBuilder.append(errorCodeEnum.getIndex()).append(", ")
                    .append("\"");
            return stringBuilder.toString();
        }
    }

    public String getType(BiRelTableEnum errorCodeEnum) {
        StringBuilder stringBuilder = new StringBuilder();
        if (Objects.equals(errorCodeEnum.getType(), null)) {
            return null;
        } else {
            stringBuilder.append(errorCodeEnum.getType()).append(", ")
                    .append("\"");
            return stringBuilder.toString();
        }
    }

    public String getMutiCode(BiRelTableEnum errorCodeEnum) {
        StringBuilder stringBuilder = new StringBuilder();
        if (Objects.equals(errorCodeEnum.getMutiCode(), null)) {
            return null;
        } else {
            stringBuilder.append(errorCodeEnum.getMutiCode()).append(", ")
                    .append("\"");
            return stringBuilder.toString();
        }
    }

    public String getRefCode(BiRelTableEnum errorCodeEnum) {
        StringBuilder stringBuilder = new StringBuilder();
        if (Objects.equals(errorCodeEnum.getRefCode(), null)) {
            return null;
        } else {
            stringBuilder.append(errorCodeEnum.getRefCode()).append(", ")
                    .append("\"");
            return stringBuilder.toString();
        }
    }

    @Test
    public void changePOJO() throws NoSuchMethodException,
            IllegalAccessException, IllegalArgumentException,
            InvocationTargetException {
        CustomCardPoJo raidersScoreDTO = new CustomCardPoJo();
        String classname = raidersScoreDTO.getClass().getSimpleName();
        classname = classname.substring(0,1).toLowerCase().concat(classname.substring(1));
        classname = classname.substring(0,classname.length()-3);
        java.lang.reflect.Field[] field = raidersScoreDTO.getClass().getDeclaredFields();
        StringBuilder stringBuilder = new StringBuilder();
        for (int j = 0; j < field.length; j++) {
            // 获取属性的名字
            String name = field[j].getName();
            // 将属性的首字符大写，方便构造get，set方法
            name = name.substring(0, 1).toUpperCase() + name.substring(1);
            // 获取属性的类型
            String type = field[j].getGenericType().toString();
            String memberName = "";
            String sizeValue = "";
            // 如果type是类类型，则前面包含"class "，后面跟类名
            //System.out.println("属性为：" + name);
            // 方法1
            Annotation[] annotations = field[j].getDeclaredAnnotations();
            //Object fieldValue = runGetter(field[j], this);
            for (Annotation annotation : annotations) {
                if (Objects.equals(JAVAX_VALIDATION_CONSTRAINTS_NOTNULL, annotation.annotationType().getName())) {
                    InvocationHandler invocationHandler = Proxy.getInvocationHandler(annotation);
                    try {
                        Field declaredField = invocationHandler.getClass().getDeclaredField("memberValues");
                        declaredField.setAccessible(true);
                        Map memberValues = (Map) declaredField.get(invocationHandler);
                        memberName = memberValues.get("message").toString();
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    }
                    stringBuilder.append(POJO_MSG).append(classname).append(".").append(field[j].getName()).append(".").append("NotNull").append("=").append(memberName);
                    System.out.println(stringBuilder.toString());
                    stringBuilder.delete(0, stringBuilder.length());
                } else if (Objects.equals(JAVAX_VALIDATION_CONSTRAINTS_NOTBLANK, annotation.annotationType().getName())) {
                    InvocationHandler invocationHandler = Proxy.getInvocationHandler(annotation);
                    try {
                        Field declaredField = invocationHandler.getClass().getDeclaredField("memberValues");
                        declaredField.setAccessible(true);
                        Map memberValues = (Map) declaredField.get(invocationHandler);
                        memberName = memberValues.get("message").toString();
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    }
                    stringBuilder.append(POJO_MSG).append(classname).append(".").append(field[j].getName()).append(".").append("NotBlank").append("=").append(memberName);
                    System.out.println(stringBuilder.toString());
                    stringBuilder.delete(0, stringBuilder.length());
                } else if (Objects.equals(ORG_HIBERNATE_VALIDATOR_CONSTRAINTS_LENGTH, annotation.annotationType().getName())) {
                    InvocationHandler invocationHandler = Proxy.getInvocationHandler(annotation);
                    try {
                        Field declaredField = invocationHandler.getClass().getDeclaredField("memberValues");
                        declaredField.setAccessible(true);
                        Map memberValues = (Map) declaredField.get(invocationHandler);
                        memberName = memberValues.get("message").toString();
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    }
                    stringBuilder.append(POJO_MSG).append(classname).append(".").append(field[j].getName()).append(".").append("Length").append("=").append(memberName);
                    System.out.println(stringBuilder.toString());
                    stringBuilder.delete(0, stringBuilder.length());
                } else if (Objects.equals(JAVAX_VALIDATION_CONSTRAINTS_MIN, annotation.annotationType().getName())) {
                    InvocationHandler invocationHandler = Proxy.getInvocationHandler(annotation);
                    try {
                        Field declaredField = invocationHandler.getClass().getDeclaredField("memberValues");
                        declaredField.setAccessible(true);
                        Map memberValues = (Map) declaredField.get(invocationHandler);
                        memberName = memberValues.get("message").toString();
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    }
                    stringBuilder.append(POJO_MSG).append(classname).append(".").append(field[j].getName()).append(".").append("Min").append("=").append(memberName);
                    System.out.println(stringBuilder.toString());
                    stringBuilder.delete(0, stringBuilder.length());
                } else if (Objects.equals(JAVAX_VALIDATION_CONSTRAINTS_MAX, annotation.annotationType().getName())) {
                    InvocationHandler invocationHandler = Proxy.getInvocationHandler(annotation);
                    try {
                        Field declaredField = invocationHandler.getClass().getDeclaredField("memberValues");
                        declaredField.setAccessible(true);
                        Map memberValues = (Map) declaredField.get(invocationHandler);
                        memberName = memberValues.get("message").toString();
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    }
                    stringBuilder.append(POJO_MSG).append(classname).append(".").append(field[j].getName()).append(".").append("Max").append("=").append(memberName);
                    System.out.println(stringBuilder.toString());
                    stringBuilder.delete(0, stringBuilder.length());
                } else if (Objects.equals(JAVAX_VALIDATION_CONSTRAINTS_NOTEMPTY, annotation.annotationType().getName())) {
                    InvocationHandler invocationHandler = Proxy.getInvocationHandler(annotation);
                    try {
                        Field declaredField = invocationHandler.getClass().getDeclaredField("memberValues");
                        declaredField.setAccessible(true);
                        Map memberValues = (Map) declaredField.get(invocationHandler);
                        memberName = memberValues.get("message").toString();
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    }
                    stringBuilder.append(POJO_MSG).append(classname).append(".").append(field[j].getName()).append(".").append("NotEmpty").append("=").append(memberName);
                    System.out.println(stringBuilder.toString());
                    stringBuilder.delete(0, stringBuilder.length());
                } else if (Objects.equals(JAVAX_VALIDATION_CONSTRAINTS_SIZE, annotation.annotationType().getName())) {
                    InvocationHandler invocationHandler = Proxy.getInvocationHandler(annotation);
                    try {
                        Field declaredField = invocationHandler.getClass().getDeclaredField("memberValues");
                        declaredField.setAccessible(true);
                        Map memberValues = (Map) declaredField.get(invocationHandler);
                        memberName = memberValues.get("message").toString();
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    }
                    stringBuilder.append(POJO_MSG).append(classname).append(".").append(field[j].getName()).append(".").append("Size").append("=").append(memberName);
                    System.out.println(stringBuilder.toString());
                    stringBuilder.delete(0, stringBuilder.length());
                } else if (Objects.equals(ORG_HIBERNATE_VALIDATOR_CONSTRAINTS_RANGE, annotation.annotationType().getName())) {
                    InvocationHandler invocationHandler = Proxy.getInvocationHandler(annotation);
                    try {
                        Field declaredField = invocationHandler.getClass().getDeclaredField("memberValues");
                        declaredField.setAccessible(true);
                        Map memberValues = (Map) declaredField.get(invocationHandler);
                        memberName = memberValues.get("message").toString();
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    }
                    stringBuilder.append(POJO_MSG).append(classname).append(".").append(field[j].getName()).append(".").append("Range").append("=").append(memberName);
                    System.out.println(stringBuilder.toString());
                    stringBuilder.delete(0, stringBuilder.length());
                } else if (Objects.equals(JAVAX_VALIDATION_CONSTRAINTS_DECIMALMIN, annotation.annotationType().getName())) {
                    InvocationHandler invocationHandler = Proxy.getInvocationHandler(annotation);
                    try {
                        Field declaredField = invocationHandler.getClass().getDeclaredField("memberValues");
                        declaredField.setAccessible(true);
                        Map memberValues = (Map) declaredField.get(invocationHandler);
                        memberName = memberValues.get("message").toString();
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    }
                    stringBuilder.append(POJO_MSG).append(classname).append(".").append(field[j].getName()).append(".").append("DecimalMin").append("=").append(memberName);
                    System.out.println(stringBuilder.toString());
                    stringBuilder.delete(0, stringBuilder.length());
                } else if (Objects.equals(JAVAX_VALIDATION_CONSTRAINTS_DECIMALMAX, annotation.annotationType().getName())) {
                    InvocationHandler invocationHandler = Proxy.getInvocationHandler(annotation);
                    try {
                        Field declaredField = invocationHandler.getClass().getDeclaredField("memberValues");
                        declaredField.setAccessible(true);
                        Map memberValues = (Map) declaredField.get(invocationHandler);
                        memberName = memberValues.get("message").toString();
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    }
                    stringBuilder.append(POJO_MSG).append(classname).append(".").append(field[j].getName()).append(".").append("DecimalMax").append("=").append(memberName);
                    System.out.println(stringBuilder.toString());
                    stringBuilder.delete(0, stringBuilder.length());
                }
            }
        }
    }
}
